<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表极客APK下载器</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" rel="stylesheet">
</head>

<body class="bg-gray-100 flex justify-center items-center h-screen">
    <div class="bg-white p-8 rounded shadow-md w-full max-w-md">
        <h1 class="text-2xl font-bold mb-4 text-center">表极客APK下载器</h1>
        <form id="downloadForm" class="space-y-4">
            <div>
                <label for="appname" class="block text-sm font-medium text-gray-700">应用名</label>
                <input type="text" id="appname" name="appname"
                    class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
            </div>
            <button type="submit"
                class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
                生成下载链接
            </button>
        </form>
        <div id="downloadLink" class="mt-4"></div>
    </div>
    <script>
        const form = document.getElementById('downloadForm');
        form.addEventListener('submit', function (e) {
            e.preventDefault();
            const appname = document.getElementById('appname').value;
            const sha256 = new jsSHA('SHA-256', 'TEXT');
            sha256.update(appname);
            const sha256_appname = sha256.getHash('HEX');
            const filename = `${appname}_${sha256_appname}.apk`;
            const url = `https://pan.leidell.cn/d/shuju/watchgeek/app/${filename}`;
            const downloadLink = document.getElementById('downloadLink');
            if (url) {
                downloadLink.innerHTML = `<a href="${url}" class="text-blue-600 hover:text-blue-800 underline">点击下载 ${appname} APK</a>`;
            } else {
                downloadLink.innerHTML = '<p class="text-red-500">无法生成下载链接</p>';
            }
        });
    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jsSHA/2.4.2/sha.js"></script>
</body>

</html>    